<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/util.js"></script>
    <script>
        let userId="";
        window.onload=function (){
            userId=getQuery("userId");
            init(1);
        }

        async function init(pageNo){
            let pageInfo=await ajaxGet("/order/findByItemAdmin",
                {pageNo:pageNo,status:null,startDate:null,
                endDate: null,id:userId});
            let orderStr="";
            for (let i=0;i<pageInfo.list.length;i++){
                let obj=pageInfo.list[i];
                orderStr+=`<tr>
                           <td>${obj.id}</td>
                           <td>${obj.money}</td>
                           <td>${obj.status}</td>
                           <td>${obj.date}</td>
                           <td><a href="/html/custom/customOrderInfo.html?orderId=${obj.id}">查看详情</a></td>
                           </tr>`
            }
            getObject("ordertb").innerHTML=orderStr;


            let pageStr="";
            for (let i=1;i<=pageInfo.pages;i++){
                pageStr+=`<a href="javascript:init(${i})" style="margin-left: 10px">${i}</a>`
            }
            getObject("pageDiv").innerHTML=pageStr;
        }

        async function back(){
            location.href="/html/index.html"
        }
    </script>
</head>
<body>
<div style="margin: 0 auto;width: 50%;height: 50%;margin-top: 100px">
    <table border="1" cellpadding="0">
        <thead>
        <tr>
            <th>订单号</th>
            <th>订单总价</th>
            <th>订单状态</th>
            <th>下单时间</th>
            <th>订单详情</th>
        </tr>
        </thead>
        <tbody id="ordertb"></tbody>
    </table>
    <div id="pageDiv" style="margin-top: 20px"></div>
    <input type="button" value="返回首页" onclick="back()" style="margin-top: 20px">
</div>
</body>
</html>